package com.itheima.case2.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.aspectj.lang.annotation.Aspect;
@Component
@Aspect
public class TimeAdvice {

    @Pointcut("execution(* com.itheima.case2.service..*.find*(..))")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint point){
        Object result = null;
        try{
            long currentTimeMillis = System.currentTimeMillis();
            result = point.proceed();
            long endTime = System.currentTimeMillis();
            String name = point.getSignature().getName();
            System.err.println(name + "运行耗时："+(endTime-currentTimeMillis));

        }catch(Throwable throwable){

        }
        return result;
    }
}
